package dasregistry.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.SimpleTimeZone;
import java.util.TimeZone;

import dasregistry.registryBean;

public class RegistryDateUtils {
	DateFormat fmt = new SimpleDateFormat("dd-MM-yyyy");
	
	
	public static void main (String args[]){
		RegistryDateUtils dateUtils=new RegistryDateUtils();
		Date registrationDate=null;
		try {
			registrationDate = dateUtils.fmt.parse("15-05-2009");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		//Date currentDate=
		dateUtils.testDate(registrationDate);
	}
	
	/**
	 * Test the registration date to see if it's past the 1.6 spec upgrade deadline 
	 * @param registrationDate
	 * @return true if newer 1.6 spec is now allowed only as this was registered after the changeover date
	 */
	public boolean testDate(Date registrationDate){
		Date specChangeOverDate=null;
		boolean shouldBe16Spec=false;
		try {
			specChangeOverDate = fmt.parse("01-07-2009");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
		      long msecDiff = registrationDate.getTime() - specChangeOverDate.getTime();  
		      int daysDiff = (int) (msecDiff / (24.0 * 60 * 60 * 1000));  
		      System.out.println(daysDiff);  
		      if(daysDiff>0){
		    	  System.out.println("returning true, should be 1.6 spec due to date of registration");
		    	  return true;
		      }
		      return false;
	  }

}
